using System.Collections.Generic;
using wpffc.contracts.domaindata;

namespace wpffc.flashcardbox.domaindata
{
    public class Batch : IBatch
    {
        private readonly Queue<BatchCard> _cards;
        private readonly int _needsRefillCount;
        private readonly int _fullCount;


        public Batch(int needsRefillCount, int fullCount) : this(new Queue<BatchCard>(), needsRefillCount, fullCount) { }
        internal Batch(Queue<BatchCard> cards, int needsRefillCount, int fullCount)
        {
            _cards = cards;
            _needsRefillCount = needsRefillCount;
            _fullCount = fullCount;
        }


        public void Enqueue(BatchCard card)
        {
            _cards.Enqueue(card);
        }

        public BatchCard Dequeue()
        {
            return _cards.Dequeue();
        }

        public BatchCard Peek()
        {
            return _cards.Peek();
        }

        public BatchStatus Status
        {
            get
            {
                if (_cards.Count == 0) return BatchStatus.Empty;
                if (_cards.Count <= _needsRefillCount) return BatchStatus.NeedsRefill;
                if (_cards.Count > _needsRefillCount && _cards.Count < _fullCount) return BatchStatus.Filled;
                return BatchStatus.Full;
            }
        }
    }
}